﻿@model PagedList<View_RefundOrder>
@{
    ViewBag.Title = "出纳退款列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    RefundQueryModel paramModel = new RefundQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (RefundQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}
<div style="width:100%;left:0;top:0;height:100%;position:fixed; display:none;" class="bui-ext-mask"></div>

<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("refundlist", "ordermaster")" method="get">
    <div class="form_query">
        <div>
            销售订单号：
            <input type="text" name="master_order_no" id="master_order_no" class="abc input-default" placeholder="" value="@paramModel.master_order_no">&nbsp;
        </div>
        <div>
            手机号：
            <input type="text" name="account_mobile" id="account_mobile" class="abc input-default" placeholder="" value="@paramModel.account_mobile">&nbsp;
        </div>
        <div>
            会员名称：
            <input type="text" name="member_name" id="member_name" class="abc input-default" placeholder="" value="@paramModel.member_name">&nbsp;
        </div>
        <div>
            代购编号：
            <input type="text" name="replace_buyer_NO" id="replace_buyer_NO" class="abc input-default" placeholder="" value="@paramModel.replace_buyer_NO">&nbsp;
        </div>
        <div>
            退款订单号：
            <input type="text" name="order_no" id="order_no" class="abc input-default" placeholder="" value="@paramModel.order_no">&nbsp;
        </div>
        <div>
            申请时间：
            <input type="text" name="beg_time" class="calendar calendar-time" id="beg_time" value="@paramModel.create_time_begin.ToString(1)"> - <input type="text" name="end_time" class="calendar calendar-time" id="end_time" value="@paramModel.create_time_end.ToString(1)">&nbsp;
        </div>
        <div>
            @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        </div><div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th>销售订单号</th>
            <th>退款订单号</th>
            <th>购买人</th>
            <th>付款方式</th>
            <th>退款金额</th>
            <th>退款状态</th>
            <th>申请时间</th>
            <th>初审状态</th>
            <th>初审时间</th>
            <th>审核人</th>
            <th>复审状态</th>
            <th>复审时间</th>
            <th>审核人</th>
            <th>转款备注</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
<tr class="@HtmlPagerHelper.TrClass(index)">
    <td>@m.master_order_no</td>
    <td>@m.order_no</td>
    <td>@m.account_mobile @m.member_name @m.replace_buyer_NO</td>
    <td>@(MyEnumHelper.GetEnumItemDescription<PayType>(m.pay_type.Value))</td>
    <td>@m.refund_amt</td>
    <td>
        @{
            int order_status = ConvertHelper.ConvertTo<int>(m.status, 0);
            switch (order_status)
            {
                case (int)RefundSatus.Apply:
                    @:<div>@(MyEnumHelper.GetEnumItemDescription<RefundSatus>(order_status))</div>
                    break;
                case (int)RefundSatus.Succ:
                    @:<div class="green">@(MyEnumHelper.GetEnumItemDescription<RefundSatus>(order_status))</div>
                    break;
                case (int)RefundSatus.Fail:
                    @:<div class="red">@(MyEnumHelper.GetEnumItemDescription<RefundSatus>(order_status))</div>
                    break;
            }
        }
    </td>
    <td>@m.create_time.ToString(1)</td>
    <td>
        @{
            int first_audit_status = ConvertHelper.ConvertTo<int>(m.first_audit_status, 0);
            switch (first_audit_status)
            {
                case (int)AuditStatus.Create:
                    @:<div>@(MyEnumHelper.GetEnumItemDescription<AuditStatus>(first_audit_status))</div>
                    break;
                case (int)AuditStatus.AuditSucc:
                    @:<div class="green">@(MyEnumHelper.GetEnumItemDescription<AuditStatus>(first_audit_status))</div>
                    break;
                case (int)AuditStatus.AuditFail:
                    @:<div class="red">@(MyEnumHelper.GetEnumItemDescription<AuditStatus>(first_audit_status))</div>
                    break;
            }
        }
    </td>
    <td>@m.first_audit_time</td>
    <td>@m.first_audit_user</td>
    <td>
        @{
            int tow_audit_status = ConvertHelper.ConvertTo<int>(m.tow_audit_status, 0);
            switch (tow_audit_status)
            {
                case (int)AuditStatus.Create:
                    @:<div>@(MyEnumHelper.GetEnumItemDescription<AuditStatus>(tow_audit_status))</div>
                    break;
                case (int)AuditStatus.AuditSucc:
                    @:<div class="green">@(MyEnumHelper.GetEnumItemDescription<AuditStatus>(tow_audit_status))</div>
                    break;
                case (int)AuditStatus.AuditFail:
                    @:<div class="red">@(MyEnumHelper.GetEnumItemDescription<AuditStatus>(tow_audit_status))</div>
                    break;
            }
        }
    </td>
    <td>@m.tow_audit_time.ToString(1)</td>
    <td>@m.tow_audit_user</td>
    <td style="white-space: pre-line;">@m.transfer_remark</td>
    <td>
        <a href="@Url.Action("refundorderinfo", "OrderMaster", new { id = m.order_id})">查看详情</a>
        @if (m.is_tranfer == 0)
        {
            @:<a href="javascript:void(0);" onclick="toDoRefuse(@m.order_id,'@m.order_no','@m.pay_type.Value')">执行退款</a>
        }
    </td>
</tr>
        }
    }
</table>

<div class="inline pull-left total">
    总行数：@ViewData["AllCount"] | 总退款金额：@ViewData["AllAmt"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>

<script>
    var cancelButton =
    {
        text: '取消',
        elCls: 'button',
        handler: function () {
            this.close();
        }
    };
    reloadHandler = function () {
        window.location.reload();
    }
</script>
<style>
    #div_Mask {
        text-align: center;
        line-height: 100px;
        font-weight: bold
    }

    #J_Form {
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,.4);
        position: absolute;
        z-index: 1000;
        top: 0;
        left: 0;
        color: #000;
    }
</style>
<div id="div_Mask" class="hide">
    <form id="J_Form">
        <table class="table table-bordered definewidth m10 " style="width:600px;margin-top:200px;background-color:#fff">
            <tr>
                <th colspan="2">
                    确定要给退款订单 <info class="red" id="order_no"></info> 执行退款吗？
                </th>
            </tr>
            <tr>
                <td class="tableleft">选择退款方式</td>
                <td class="">
                    <select id="backroad">
                        <option value="">选择退款方式</option>
                        <option value="2">退回到余额</option>
                        <option value="3">支付宝原路退回</option>
                        <option value="4">微信原路退回</option>
                        <option value="0">线下转账</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="tableleft">退款描述</td>
                <td class="tableleft">
                    <textarea name="transfer_remark" id="transfer_remark" style="width:90%;" placeholder="填入转账银行、金额等附加信息" maxlength="250" rows="6"></textarea>
                </td>
            </tr>
            @*<tr>
            <td class="tableleft">银行</td>
            <td>
                @Html.Action("BankDropList", "Common", new { EleAttr = new ElementAttribute { Class = "sce-wid02", Name = "bankId" } })
            </td>
        </tr>*@
            <tr>
                <td></td>
                <td>
                    <button type="button" class="btn btn-primary" id="btn_saveexp">提交</button> &nbsp;&nbsp;
                    <button type="button" class="btn btn-success" id="btn_cancel">取消</button>
                </td>
            </tr>
        </table>
    </form>
</div>
<script>
    var seq_id = 0;
    function toDoRefuse(id,orderno,pay_type) {
        seq_id = id;
        $("#backroad").val(pay_type);
        $("#order_no").text(orderno +"");
        $("#div_Mask").show();
    }
    $("#btn_cancel").click(function () {
        $("#div_Mask").hide();
    });
    $("#btn_saveexp").click(function () {
        var transfer_remark = $("#transfer_remark").val();
        var backroad = $("#backroad").val();

        BUI.Message.Show({
            title: '提示',
            msg: '确定要转款吗？',
            icon: 'question',
            buttons: [
                {
                    text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                        url = "@Url.Action("tranfer", "ordermaster")";
                        parameter = {
                            orderId: seq_id,
                            backroad: backroad,
                            transfer_remark:transfer_remark
                        };
                        $.post(url, parameter, function (result) {
                            ShowActionResult(result, reloadHandler);
                            $("#div_Mask").hide();
                        });
                        this.close();
                    }
                },
                cancelButton
            ]
        });
    });

</script>

